import axios from "@/axios"

export function getArticleDetail(articleId) {
    return axios.post("/article/detail", {articleId})
}

// 点赞/取消点赞文章
export function toggleArticleLike(articleId) {
    return axios.post("/article/like/toggle", {articleId})
}

// 获取文章点赞状态
export function getArticleLikeStatus(articleId) {
    return axios.get(`/article/like/status?articleId=${articleId}`)
}

// 收藏/取消收藏文章
export function toggleArticleFavorite(articleId) {
    return axios.post("/article/favorite/toggle", {articleId})
}

// 获取文章收藏状态
export function getArticleFavoriteStatus(articleId) {
    return axios.get(`/article/favorite/status?articleId=${articleId}`)
}

// 搜索文章 - 使用index/article/list接口，该接口已实现并支持searchTitle参数
export function searchArticles(params) {
    return axios.post("/index/article/list", params)
}

// 搜索文章，不携带Token，用于公开访问
export function searchArticlesPublic(params) {
    // 创建一个新的axios实例而不添加token
    return axios({
        method: 'post',
        url: '/index/article/list',
        data: params,
        skipAuthCheck: true // 自定义标志，告诉拦截器跳过认证检查
    })
}


